#!/usr/bin/env bash

export LANG="en_US.UTF-8"

COMMAND=$1

SSH_ID="./ssh/resource.key"
SSH_PORT="22"

DEST_HOST="139.199.172.253"

function setColor()
{
        tput setaf $1 2>/dev/null
}

function resetColor()
{
        tput sgr0 2>/dev/null
}

function echoColor() {
    setColor 6
    echo $1
    resetColor
}

function ssh_exec() {
    cmd=$1
    host=$DEST_HOST
    echoColor "==> run cmd on host:${host}: ${cmd}"
    ssh -i ${SSH_ID} -p ${SSH_PORT} root@${host} "${cmd}"

    # echo "==> ssh -i ${SSH_ID} root@${host} \"${cmd}\""
}

# ssh-copy-id -i ./ssh/resource.key    root@139.199.172.253
ssh_exec "sh /root/data/ss5/ss5-netty/runProd.sh"
